<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <my-parent></my-parent>
    </div>
    <template id="son">
        <div>
       {{ this.$parent.msg }}     
        </div>
    </template>
    
    <template id="father">
        <div>
            <my-son></my-son>            
        </div>
    </template>
    
    <script>
    const son = {
        template: '#son',
        mounted() {
            console.log(this.$parent.msg)
        }
    }

    const father = {
        template: '#father',
        data() {
            return {
                msg: '我是父组件的数据'
            }
        },
        components: {
            'mySon': son
        }
    }
    new Vue({
        el: '#app',
        components: {
            'myParent': father 
        }
    })
    </script>
</body>
</html>